{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8b0610e6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import yaml\n",
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "294f14f7",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('yaml_test.yaml', 'r', encoding='utf8') as yamls:\n",
    "    ya = yaml.load(yamls, Loader=yaml.FullLoader)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "a6fc6537",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'forMac': {'name': '这是一个测试', 'yaml_name': 'cccc'},\n",
       " 'maya_pip': {'name': 'namename', 'yaml_name': 124455},\n",
       " 'nnn': ['aaa', 'bbb', 'ccc']}"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ya"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "baf580f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(ya)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2606b1f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = {'keys':{'a':1,'b':2},'key_list':[1,2,3,45]}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "3539c31d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'keys': {'a': 1, 'b': 2}, 'key_list': [1, 2, 3, 45]}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "4ce0386a",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('yaml_t.yaml', 'w', encoding='utf8') as w:\n",
    "    yaml.dump(data, w, allow_unicode=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "a8f989b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "with open('yaml_t.yaml', 'r', encoding='utf8') as r:\n",
    "    y = yaml.load(r, Loader=yaml.FullLoader)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2441896f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'key_list': [1, 2, 3, 45], 'keys': {'a': 1, 'b': 2}}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "0459693e",
   "metadata": {},
   "outputs": [],
   "source": [
    "os.startfile(os.path.abspath(''))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2055a10d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
